package de.hatraco.funderberg.blackjack.views;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;

import de.hatraco.funderberg.blackjack.data.DataMISC;
import de.hatraco.funderberg.blackjack.data.GraphicsBlackJack;

public class OutofstackDialog extends JDialog {
	
	//Singleton Pattern: Stellt sicher, dass nur eine Instanz von OutofstackDialog existiert
	private static OutofstackDialog instance = new OutofstackDialog();

	public static OutofstackDialog getInstance() {
		if(instance == null) {
			instance = new OutofstackDialog();
		}
		return instance;
	}

	private JLabel bg_outofstack;
	private JLabel outofstack1;
	private JLabel outofstack2;
		
	private JButton b_ok;
		
	//private String link = DataMISC.LINKIMG;
	
	private GraphicsBlackJack img;
	
	private OutofstackDialog() {
		
		//Instanziert GraphicsBlackJack (für die Bilder)
		this.img = GraphicsBlackJack.getInstance();
		
		//Legt die Größe des Fensters fest
		this.setSize(400,300);
		//Legt fest, dass die Größe nicht verändert werden kann
		this.setResizable(false);
		//Legt fest, dass das Fenster nicht über das "X" rechts oben geschlossen werden kann
		this.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
		//Gibt dem Fenster ein BorderLayout
		this.setLayout(new BorderLayout());
		//Legt den Hintergrund fest		
		bg_outofstack = new JLabel(img.getBgoutofstack());
		//Fügt den Hintergrund hinzu
        this.add(bg_outofstack);
        //Gibt dem Hintergrund ein "leeres" Layout
        bg_outofstack.setLayout(null);
        
        //Instanziert, Modifiziert und Positioniert die Elemente
        //JLabels
        outofstack1 = new JLabel("");
        outofstack1.setFont(DataMISC.ARIAL_BOLD30);
        outofstack1.setForeground(Color.WHITE);
        outofstack1.setBounds(20, 40, 400, 25);
        outofstack1.setVisible(false);
        
        outofstack2 = new JLabel("is out of stack!");
        outofstack2.setFont(DataMISC.ARIAL_BOLD30);
        outofstack2.setForeground(Color.WHITE);
        outofstack2.setBounds(20, 80, 400, 25);
        outofstack2.setVisible(false);
        
        //Button
        b_ok = new JButton(img.getBtok());
        b_ok.setBounds(60, 195, 60, 40);
        b_ok.setVisible(false);
        
        //Fügt die Elemente dem Hintergrund hinzu
        bg_outofstack.add(outofstack1);
        bg_outofstack.add(outofstack2);
        bg_outofstack.add(b_ok);
    }
	
	//Definiert Listener für den Button
	public void setOutofstackListener(ActionListener ae) {
		this.b_ok.addActionListener(ae);
	}
	
	public JLabel getBg_outofstack() {
		return bg_outofstack;
	}

	public void setBg_outofstack(JLabel bg_outofstack) {
		this.bg_outofstack = bg_outofstack;
	}

	public JLabel getOutofstack1() {
		return outofstack1;
	}

	public void setOutofstack1(JLabel outofstack1) {
		this.outofstack1 = outofstack1;
	}

	public JLabel getOutofstack2() {
		return outofstack2;
	}

	public void setOutofstack2(JLabel outofstack2) {
		this.outofstack2 = outofstack2;
	}
	
	public JButton getB_ok() {
		return b_ok;
	}

	public void setB_ok(JButton b_ok) {
		this.b_ok = b_ok;
	}
}
